hysop.operator.derivative module¶
- class hysop.operator.derivative.FiniteDifferencesSpaceDerivative(F, dF, A=None, derivative=None, direction=None, name=None, pretty_name=None, variables=None, implementation=None, base_kwds=None, **kwds)[source]¶
Bases:
SpaceDerivative
Operator frontend to compute the derivative of a component of a field in a given direction using finite differences.
/!FiniteDifferencesSpaceDerivative only supports directional derivatives /!
SpaceDerivative operator frontend.
Compute the derivative of a field in a given direction on a given backend, possibly scaled by another field/parameter/value.
- dF = A * dF^m/d(x0^k0 x1^k1 … xn^kn)
where k
- where F is an input field
dF is an output field A is a Field, a Parameter or a scalar. (k0,…,kn) are positive integers m=sum(ki) n=F.dim-1
- Parameters:
F (hysop.field.continuous_field.Field) – Continuous field as input.
dF (hysop.field.continuous_field.Field) – Continuous field to be written. Some backend may allow inplace differentiation.
A (numerical value, ScalarParameter or Field, optional) – Scaling for convenience.
derivative (int or tuple, optional) – Which derivative to generate, defaults to (0,)*(dim-1)+(1,). ie. first order derivative in X axis. If integer is given, the derivative is taken in given direction.
direction (int, optional) – Directions in which to take the derivative. Defaults to None. Should be None if derivative is a tuple.
name (str, optional) – Name of this operator.
pretty_name (str, optional) – Pretty name of this operator.
variables (dict, optional) – Dictionary of fields as keys and topology descriptors as values.
implementation (Implementation, optional, defaults to None) – target implementation, should be contained in available_implementations(). If None, implementation will be set to default_implementation().
base_kwds (dict, optional) – Base class keyword arguments.
kwds (dict, optional) – Extra parameters passed towards operator implementation.
Notes
- There is two way to build a derivative:
- derivative(int) + direction(int) gives:
- => derivative=(0,0,0,0,kd,0,0,0)
where the index of kd is direction and kd=derivative
- derivative(tuple) + direction(None) gives:
=> derivative=(k0,…,kn)
- class hysop.operator.derivative.MultiSpaceDerivatives(Fs, dFs, As=None, cls=<class 'hysop.operator.derivative.FiniteDifferencesSpaceDerivative'>, directions=None, derivatives=None, extra_params=None, base_kwds=None, variables=None, **op_kwds)[source]¶
Bases:
DirectionalOperatorGeneratorI
,ComputationalGraphNodeGenerator
Generate multiple SpaceDerivative operators at once.
Create a operator generator that can handle multiple SpaceDerivative operators. Operators are created in input parameter order.
Tuple parameters are zipped together with vectorized scalar parameters. The number of operators is determined by len(Fs) and len(dFs). If any parameter has not the expected size (ie. len(Fs) or 1), a ValueError is raised.
This operator can also be used as a directional operator generator.
Refer to hysop.operator.derivative.SpaceDerivative for all arguments.
- class hysop.operator.derivative.SpaceDerivative(F, dF, A=None, derivative=None, direction=None, name=None, pretty_name=None, variables=None, implementation=None, base_kwds=None, **kwds)[source]¶
Bases:
ComputationalGraphNodeFrontend
Operator frontend to compute the derivative of a component of a field in a given direction using a given method.
- Currently two methods are supported:
*Finite differences: FiniteDifferencesSpaceDerivative *Spectral method: SpectralSpaceDerivative
Those two classes can be passed to the more general MultiSpaceDerivatives and Gradient operator generators via the ‘cls’ keyword argument during __init__.
SpaceDerivative operator frontend.
Compute the derivative of a field in a given direction on a given backend, possibly scaled by another field/parameter/value.
- dF = A * dF^m/d(x0^k0 x1^k1 … xn^kn)
where k
- where F is an input field
dF is an output field A is a Field, a Parameter or a scalar. (k0,…,kn) are positive integers m=sum(ki) n=F.dim-1
- Parameters:
F (hysop.field.continuous_field.Field) – Continuous field as input.
dF (hysop.field.continuous_field.Field) – Continuous field to be written. Some backend may allow inplace differentiation.
A (numerical value, ScalarParameter or Field, optional) – Scaling for convenience.
derivative (int or tuple, optional) – Which derivative to generate, defaults to (0,)*(dim-1)+(1,). ie. first order derivative in X axis. If integer is given, the derivative is taken in given direction.
direction (int, optional) – Directions in which to take the derivative. Defaults to None. Should be None if derivative is a tuple.
name (str, optional) – Name of this operator.
pretty_name (str, optional) – Pretty name of this operator.
variables (dict, optional) – Dictionary of fields as keys and topology descriptors as values.
implementation (Implementation, optional, defaults to None) – target implementation, should be contained in available_implementations(). If None, implementation will be set to default_implementation().
base_kwds (dict, optional) – Base class keyword arguments.
kwds (dict, optional) – Extra parameters passed towards operator implementation.
Notes
- There is two way to build a derivative:
- derivative(int) + direction(int) gives:
- => derivative=(0,0,0,0,kd,0,0,0)
where the index of kd is direction and kd=derivative
- derivative(tuple) + direction(None) gives:
=> derivative=(k0,…,kn)
- classmethod default_implementation()[source]¶
Return the default Implementation, should be compatible with available_implementations.
- class hysop.operator.derivative.SpectralSpaceDerivative(F, dF, A=None, derivative=None, direction=None, name=None, pretty_name=None, variables=None, implementation=None, base_kwds=None, **kwds)[source]¶
Bases:
SpaceDerivative
Operator frontend to compute the derivative of a component of a field in a given direction using spectral methods.
SpaceDerivative operator frontend.
Compute the derivative of a field in a given direction on a given backend, possibly scaled by another field/parameter/value.
- dF = A * dF^m/d(x0^k0 x1^k1 … xn^kn)
where k
- where F is an input field
dF is an output field A is a Field, a Parameter or a scalar. (k0,…,kn) are positive integers m=sum(ki) n=F.dim-1
- Parameters:
F (hysop.field.continuous_field.Field) – Continuous field as input.
dF (hysop.field.continuous_field.Field) – Continuous field to be written. Some backend may allow inplace differentiation.
A (numerical value, ScalarParameter or Field, optional) – Scaling for convenience.
derivative (int or tuple, optional) – Which derivative to generate, defaults to (0,)*(dim-1)+(1,). ie. first order derivative in X axis. If integer is given, the derivative is taken in given direction.
direction (int, optional) – Directions in which to take the derivative. Defaults to None. Should be None if derivative is a tuple.
name (str, optional) – Name of this operator.
pretty_name (str, optional) – Pretty name of this operator.
variables (dict, optional) – Dictionary of fields as keys and topology descriptors as values.
implementation (Implementation, optional, defaults to None) – target implementation, should be contained in available_implementations(). If None, implementation will be set to default_implementation().
base_kwds (dict, optional) – Base class keyword arguments.
kwds (dict, optional) – Extra parameters passed towards operator implementation.
Notes
- There is two way to build a derivative:
- derivative(int) + direction(int) gives:
- => derivative=(0,0,0,0,kd,0,0,0)
where the index of kd is direction and kd=derivative
- derivative(tuple) + direction(None) gives:
=> derivative=(k0,…,kn)